package com.by.facade.enums.order;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum OrderStatusEnum {

    INIT(1, "初始化"),
    PAYING(2, "支付中"),
    SUCCESS(3, "支付成功"),
    CLOSE(4, "订单关闭"),
    REFUND(5, "已退款"),
    ;

    private Integer code;
    private String desc;

    private static final Map<Integer, OrderStatusEnum> MAP = Arrays.stream(OrderStatusEnum.values())
            .collect(Collectors.toMap(OrderStatusEnum::getCode, Function.identity()));


    public static OrderStatusEnum resolve(Integer code) {
        return MAP.get(code);
    }

}
